/*
 * Created by SharpDevelop.
 * User: adriano.ribeiro
 * Date: 10/8/2007
 * Time: 9:07
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections.Generic;


namespace MonORF.Overlay
{
	/// <summary>
	/// Description of IRouting.
	/// </summary>
	public interface IRouting
	{
	   
	   event EventHandler<DeliverEventArgs> OnDeliver;
	   event EventHandler<ForwardEventArgs> OnForward;
	   event EventHandler<RouteEventArgs> OnRoute;
	   
		/**
       ** chimera_join:
       ** Join the network that the bootstrap host is a part of
       */
      void Join ( ChimeraHost bootstrap);

      /**
       * chimera_route:
       * Send a message msg through the system to key. hint is currently
       * ignored, but it will one day be the next hop
       */
      void Route<TMessage> (Key key, TMessage message, ChimeraHost hint);


      /**
       ** chimera_forward:
       ** Set the chimera forward upcall to func. This handler will be called every
       ** time a message is routed to a key through the current node. The host argument
       ** is upsupported, but will allow the programmer to choose the next hop
       * void chimera_forward (ChimeraState * state, chimera_forward_upcall_t func);
       */
      void Forward ();
      
      /**
       ** chimera_deliver:
       ** Set the chimera deliver upcall to func. This handler will be called every
       ** time a message is delivered to the current node
       */
      void Deliver ();
      

      /** chimera_update:
       ** Set the chimera update upcall to func. This handler will be called every
       ** time a host leaves or joins your neighbor set. The final integer is a 1 if
       ** the host joins and a 0 if the host leaves
       */
      //void chimera_update (ChimeraState * state, chimera_update_upcall_t func);
      void Update();


      /** chimera_setkey:
       ** Manually sets the key for the current node
       */
      //void chimera_setkey (ChimeraState * state, Key key);

      /** chimera_register:
       ** register an integer message type to be routed by the chimera routing layer
       ** ack is the argument that defines wether this message type should be acked or not
       ** ack ==1 means message will be acknowledged, ack=2 means no acknowledge is necessary
       ** for this type of message.
       */
      //void chimera_register (ChimeraState * state, int type, int ack);

      /** chimera_send:
       ** Route a message of type to key containing size bytes of data. This will
       ** send data through the Chimera system and deliver it to the host closest to the
       ** key
       */
      //void chimera_send (ChimeraState * state, Key key, int type, int len, char *data);
      void Send<TMessage> ( Key key, TMessage message);
      
      
      /**
       ** chimera_ping:
       ** sends a ping message to the host. the message is acknowledged in network layer
       * //int chimera_ping (ChimeraState * state, ChimeraHost * host);
       */
      void Ping(ChimeraHost host);
      
	}
}
